#!/usr/bin/env bash

set -e

cargo llvm-cov show-env --export-prefix "$@" > envsh
source ./envsh
cargo llvm-cov clean --workspace

env SLOW_TESTS=1 cargo test --locked --all-features

if [ `uname -p` == "x86_64" ] ; then
    env GRAVIOLA_CPU_DISABLE_sha=1 GRAVIOLA_CPU_DISABLE_bmi2=1 GRAVIOLA_CPU_DISABLE_avx512bw=1 GRAVIOLA_CPU_DISABLE_avx512f=1 GRAVIOLA_CPU_DISABLE_vaes=1 cargo test --locked
    env CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="sde -dmr --" cargo test --locked
fi
cargo run --example client https://jbp.io >/dev/null

cargo llvm-cov report "$@"
